package com.nbsaas.boot;

import java.util.Arrays;
import java.util.List;

/**
 * RegexExtractor测试类
 */
public class RegexExtractorTest {
    
    public static void main(String[] args) {
        RegexExtractor extractor = new RegexExtractor();
        
        // 显示配置统计信息
        System.out.println(RegexExtractor.getConfigStats());
        
        // 测试用例1: 标准格式
        System.out.println("=== 测试用例1: 标准格式 ===");
        List<String> words1 = Arrays.asList("13800138000", "14:30去电", "120秒钟");
        testExtraction(extractor, words1);
        
        // 测试用例2: 宽松格式
        System.out.println("\n=== 测试用例2: 宽松格式 ===");
        List<String> words2 = Arrays.asList("13800138000", "14:30", "120秒");
        testExtraction(extractor, words2);
        
        // 测试用例3: 不完整格式
        System.out.println("\n=== 测试用例3: 不完整格式 ===");
        List<String> words3 = Arrays.asList("13800138000", "14:30");
        testExtraction(extractor, words3);
        
        // 测试用例4: 特殊格式
        System.out.println("\n=== 测试用例4: 特殊格式 ===");
        List<String> words4 = Arrays.asList("13800138000", "14:30来电", "120分钟");
        testExtraction(extractor, words4);
        
        // 测试用例5: 完全无法匹配
        System.out.println("\n=== 测试用例5: 完全无法匹配 ===");
        List<String> words5 = Arrays.asList("未知号码", "未知时间", "未知时长");
        testExtraction(extractor, words5);
    }
    
    private static void testExtraction(RegexExtractor extractor, List<String> words) {
        System.out.println("输入文字: " + words);
        
        RegexExtractor.ExtractionResult result = extractor.extractWithConfigs(words);
        
        System.out.println("提取结果: " + result.getExtractedInfo());
        System.out.println("匹配的模式: " + result.getMatchedPatterns());
        System.out.println("是否完整提取: " + result.isComplete());
        System.out.println("成功率: " + String.format("%.2f%%", result.getSuccessRate() * 100));
        System.out.println("总配置数: " + result.getTotalPatterns() + ", 匹配数: " + result.getMatchedPatterns().size());
        
        if (result.isComplete()) {
            System.out.println("✅ 完整提取成功，可以直接使用结果");
        } else {
            System.out.println("❌ 提取不完整，需要调用AI处理");
        }
    }
} 